// mobile bind
// ============

define(['zepto', 'sui', 'submitForm'], function($){
  return {
    init: function(data) {
      this.courseRoundId = data.courseRoundId;
      
      this.submit()
    },
    
    submit : function() {
      var that = this;

      $(".save-button").on("click", function() {
        var weight = $('input[name="weight"]').val().trim();
        var bodyFatRate = $('input[name="bodyFatRate"]').val().trim();
        var bust = $('input[name="bust"]').val().trim();
        var waist = $('input[name="waist"]').val().trim();
        var hips = $('input[name="hips"]').val().trim();
        var expression = /^[0-9]+([.]{1}[0-9]+){0,1}$/;
        if(weight && !expression.test(weight)) {
          $.toast("请输入正确的体重");
          return false;
        } else if(bodyFatRate && !expression.test(bodyFatRate)) {
          $.toast("请输入正确的体脂率");
          return false;
        } else if(bust && !expression.test(bust)) {
          $.toast("请输入正确的胸围");
          return false;
        } else if(waist && !expression.test(waist)) {
          $.toast("请输入正确的腰围");
          return false;
        } else if(hips && !expression.test(hips)) {
          $.toast("请输入正确的臀围");
          return false;
        }
        
        $(".submit-btn").trigger("click");
      });
      
      $("form").submitform({
          successUrl: $(".fs-header-small a").attr("href")
      });
    }
  }
})

